package Command;

import java.io.File;

import Control.ICommandExecutor;

public class MkDir implements ICommandExecutor {
	private MkDir(){}
	private static MkDir instance;
	public static ICommandExecutor getInstance()
	{
		if (instance == null)
		{
			instance = new MkDir();
		}
		return instance;
	}
	public void execute(String commandString) {
		String[] cmd = commandString.split(" ");
		mkDir(cmd[1],cmd[2]);
	}
	
	private void mkDir(String dir, String dirName)
	{
		if (new File(dir).exists() && new File(dir).isDirectory())
		{
			if (new File(dir+"\\"+dirName).exists())
				System.out.println("Directory is exist");
			else	
			{
				File newFolder = new File(dir+"\\"+dirName);
				newFolder.mkdir();
			}
		}
		else
		{
			System.out.println("Operation Fail");
		}
	}

}
